﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SyndicateBusiness.Classes
{
    public class ResultObject
    {
        //15-Jun-2011,9,25,38,29,37,32,28,2,GUINEVERE

        public ResultObject(string text)
        {
            string[] array = text.Split(',');

            this.DrawDate = array[0];
            this.Ball_1 = array[1];
            this.Ball_2 = array[2];
            this.Ball_3 = array[3];
            this.Ball_4 = array[4];
            this.Ball_5 = array[5];
            this.Ball_6 = array[6];
            this.BonusBall = array[7];
            this.BallSet = array[8];
            this.Machine = array[9];
            this.Raffle = array[10];
        }

        public string DrawDate
        {
            get;
            set;
        }
        public string Ball_1
        {
            get;
            set;
        }
        public string Ball_2
        {
            get;
            set;
        }
        public string Ball_3
        {
            get;
            set;
        }
        public string Ball_4
        {
            get;
            set;
        }
        public string Ball_5
        {
            get;
            set;
        }
        public string Ball_6
        {
            get;
            set;
        }
        public string BonusBall
        {
            get;
            set;
        }
        public string BallSet
        {
            get;
            set;
        }
        public string Machine
        {
            get;
            set;
        }

        public string Raffle
        {
            get;
            set;
        }

        public string ResultWithBonus
        {
            get { return String.Format("{0},{1}", Result, this.BonusBall); }
        }

        public string Result
        {
            get { return String.Format("{0},{1},{2},{3},{4},{5}", this.Ball_1, this.Ball_2, this.Ball_3, this.Ball_4, this.Ball_5, this.Ball_6); }
        }
        public List<int> ResultList
        {
            get
            {
                List<int> r = new List<int>();

                r.Add(Int32.Parse(this.Ball_1));
                r.Add(Int32.Parse(this.Ball_2));
                r.Add(Int32.Parse(this.Ball_3));
                r.Add(Int32.Parse(this.Ball_4));
                r.Add(Int32.Parse(this.Ball_5));
                r.Add(Int32.Parse(this.Ball_6));
               
                r.Sort();

                return r;
            
            }
        }

        public List<int> ResultListWithBonus
        {
            get
            {
                List<int> r = new List<int>();

                r.AddRange(ResultList);

                r.Add(Int32.Parse(this.BonusBall));

                return r;

            }
        }

    }

    public class ResultObjectEuroMIllions
    {
        // 07-Jun-2011,25,38,40,6,36,10,4,"MVY348186,MVZ001857"

        public ResultObjectEuroMIllions(string text)
        {
            if (text.Contains('"'))
            {

                var temp = text.Split('"').ToList().Where(s => s != String.Empty).ToArray();

                string[] array = temp[0].Split(',');

                this.DrawDate = array[0];
                this.Ball_1 = array[1];
                this.Ball_2 = array[2];
                this.Ball_3 = array[3];
                this.Ball_4 = array[4];
                this.Ball_5 = array[5];
                this.LuckyStar_1 = array[6];
                this.LuckyStar_2 = array[7];
                this.Raffle = temp[1];

            }
            else
            {
                
                string[] array = text.Split(',');

                this.DrawDate = array[0];
                this.Ball_1 = array[1];
                this.Ball_2 = array[2];
                this.Ball_3 = array[3];
                this.Ball_4 = array[4];
                this.Ball_5 = array[5];
                this.LuckyStar_1 = array[6];
                this.LuckyStar_2 = array[7];
                this.Raffle = array[8];
            }
            
        }

        public string DrawDate
        {
            get;
            set;
        }
        public string Ball_1
        {
            get;
            set;
        }
        public string Ball_2
        {
            get;
            set;
        }
        public string Ball_3
        {
            get;
            set;
        }
        public string Ball_4
        {
            get;
            set;
        }
        public string Ball_5
        {
            get;
            set;
        }
        public string LuckyStar_1
        {
            get;
            set;
        }
        public string LuckyStar_2
        {
            get;
            set;
        }
        public string Raffle
        {
            get;
            set;
        }        

        

        public string Result
        {
            get { return String.Format("{0},{1},{2},{3},{4},{5},{6}", this.Ball_1, this.Ball_2, this.Ball_3, this.Ball_4, this.Ball_5, this.LuckyStar_1,this.LuckyStar_2); }
        }

        public List<int> Results
        {
            get
            {
                List<int> r = new List<int>();

                r.Add(Int32.Parse(this.Ball_1));
                r.Add(Int32.Parse(this.Ball_2));
                r.Add(Int32.Parse(this.Ball_3));
                r.Add(Int32.Parse(this.Ball_4));
                r.Add(Int32.Parse(this.Ball_5));               

                r.Sort();

                return r;

            }
        }

        public List<int> ResultsLuckyStars
        {
            get
            {
                List<int> r = new List<int>();

                r.Add(Int32.Parse(this.LuckyStar_1));
                r.Add(Int32.Parse(this.LuckyStar_2));
                r.Sort();

                return r;

            }
        }
       

    }
}
